home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!panix!not-for-mail
- From: lmb@panix.com (Lance Ball)
- Newsgroups: comp.lang.c
- Subject: pointer to pointer to int
- Date: 23 Feb 1996 11:43:46 -0500
- Organization: PANIX Public Access Internet and UNIX, NYC
- Message-ID: <4gkqs2$gbn@panix2.panix.com>
- NNTP-Posting-Host: panix2.panix.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hi. I'm trying to emulate a very basic CPU scheduler for an OS class
- and I keep getting a core dump with my code. It compiles fine, but I
- can't run it. Here is what I am doing (sorta'):
-
- struct PCB {
- int *programCounter;
- void *localvars;
- void (*proc)(void);
- } proctable[MAX_PROC];
-
- int *pc; // global
- void *lv; //global
- void badproc(void);
-
- int main(void)
- {
- int count = 100;
- int curprocess;
- PCB *pp = new PCB;
- while (count > 0) {
- curprocess = rand()%MAX_PROCS;
- *pp = proctable[curprocess];
- pp->programCounter = 0;
- pc = pp->programCounter;
- // more code
- pp->proc = badproc;
- (pp->proc)();
- count--;
- }
- return 0;
- }
-
- void badproc(void)
- {
- switch(*pc) {
- case 0: statement1; *pc++; break;
- case 1: statement2; *pc++; break;
- .
- .
- .
- }
-
- Anyway, the problem seems to be with the *pc variable, but I can't
- pinpoint where. Does anyone have any ideas about how I might be
- able to execute this code?
-
- Thanks,
-
- LB
- --
- Lance M. Ball |Imagination is greater than knowledge. -A.E.
- adobe theatre co. | lmb@panix.com
- http://www.panix.com/~lmb/adobe | lball@stern.nyu.edu
-
-